<template>
    <div>
        <el-card>
        <el-form ref="form" :model="form" label-width="80px" method="get">
            <el-form-item label="用户姓名">
                <el-input v-model="form.username" type="text" name="username" id="username" style="width:500px"></el-input>
            </el-form-item>
            <el-form-item label="用户密码">
                <el-input v-model="form.password" type="password" name="password" id="password" style="width:500px"></el-input>
            </el-form-item>
            <el-form-item label="记住密码">
                <el-select v-model="form.rem" style="width:500px">
                    <el-option label="不记住" value="0"></el-option>
                    <el-option label="一天" value="1"></el-option>
                    <el-option label="半个月" value="15"></el-option>
                    <el-option label="一个月" value="30"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit(form)">提交</el-button>
            </el-form-item>
        </el-form>
        </el-card>
    </div>
</template>


<script>
export default {
    data(){
        return {
            form:{
                username:'',
                password:'',
                rem:''
            }
        }
    },
    methods:{
        onSubmit(form){
            console.log((form.rem))
            if(form.username !=''&& form.password !=''){
                this.Cookies.set('form.username',form.username,{expires: Number(form.rem)})
                this.Cookies.set('form.password',form.password,{expires: Number(form.rem)})
            }
            
        }
    },
    created(){

        if(this.Cookies.get('form.username') && this.Cookies.get('form.password')){
            this.form.username=this.Cookies.get('form.username')
            this.form.password=this.Cookies.get('form.password')
        }

    }
}


</script>